Skip to contentSkip to conversation

Change in openvpn[master]: Change API of init_key_ctx to use struct key_paramters

Openvpn-devel In review plaisthos (Code Review) 2 participants 12 messages Nov 11, 2024 – Dec 27, 2024 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1731290343000.I4a981c5a70717e2276d89bf83a06c7fdbe6712d7@...2715...

#1 lore raw

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/801?usp=email

to review the following change.

Change subject: Change API of init_key_ctx to use struct key_paramters
......................................................................

Change API of init_key_ctx to use struct key_paramters

This introduces a new structure key_paramters. The reason is that the current struct serves both as an internal struct as well as an on-wire/in-file format. Separate these two different usages to allow extending the struct.

Change-Id I4a981c5a70717e2276d89bf83a06c7fdbe6712d7

---
M src/openvpn/auth_token.c
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/tls_crypt.c
M tests/unit_tests/openvpn/test_auth_token.c
M tests/unit_tests/openvpn/test_tls_crypt.c

6 files changed, 85 insertions(+), 37 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/801/1

src/openvpn/auth_token.c +4 -1
index 192c7c2..3cf55e8 100644
@@ -152,7 +152,10 @@
     {
         msg(M_FATAL, "ERROR: not enough data in auth-token secret");
     }
-    init_key_ctx(key_ctx, &key, &kt, false, "auth-token secret");
+
+    struct key_parameters key_params;
+    key_parameters_from_key(&key_params, &key);
+    init_key_ctx(key_ctx, &key_params, &kt, false, "auth-token secret");
 
     free_buf(&server_secret_key);
 }
src/openvpn/crypto.c +36 -21

118 lines not on this page · raw message

src/openvpn/crypto.h +31 -8
index 3331672..ff24f87 100644
@@ -144,7 +144,8 @@
 
 /**
  * Container for unidirectional cipher and HMAC %key material.
- * @ingroup control_processor
+ * @ingroup control_processor. This is used as a wire format/file format
+ * key, so it cannot be changed to add fields or change the length of fields
  */
 struct key
 {
@@ -154,6 +155,30 @@
     /**< %Key material for HMAC operations. */
 };
 
+/** internal structure similar to struct key that hold key information
+ * but is not represented on wire and can be changed/extended
+ */
+struct key_parameters {
+    /** %Key material for cipher operations. */
+    uint8_t cipher[MAX_CIPHER_KEY_LENGTH];
+
+    /** Number of bytes set in the cipher key material */
+    int cipher_size;
+
+    /** %Key material for HMAC operations. */
+    uint8_t hmac[MAX_HMAC_KEY_LENGTH];
+
+    /** Number of bytes set in the HMac key material */
+    int hmac_size;
+};
+
+/**
+ * Converts a struct key representation into a struct key_params representation.
+ * @param key_params    destination for the converted struct
+ * @param key           source of the conversion
+ */
+void
+key_parameters_from_key(struct key_parameters *key_params, const struct key *key);
 
 /**
  * Container for one set of cipher and/or HMAC contexts.
@@ -340,19 +365,17 @@
  * Key context functions
  */
 
-void init_key_ctx(struct key_ctx *ctx, const struct key *key,
+void init_key_ctx(struct key_ctx *ctx, const struct key_parameters *key,
                   const struct key_type *kt, int enc,
                   const char *prefix);
 
 void
-init_key_bi_ctx_send(struct key_ctx *ctx, const struct key2 *key2,
-                     int key_direction, const struct key_type *kt,
-                     const char *name);
+init_key_bi_ctx_send(struct key_ctx *ctx, const struct key_parameters *key,
+                     const struct key_type *kt, const char *name);
 
 void
-init_key_bi_ctx_recv(struct key_ctx *ctx, const struct key2 *key2,
-                     int key_direction, const struct key_type *kt,
-                     const char *name);
+init_key_bi_ctx_recv(struct key_ctx *ctx, const struct key_parameters *key,
+                     const struct key_type *kt, const char *name);
 
 void free_key_ctx(struct key_ctx *ctx);
 
src/openvpn/tls_crypt.c +5 -1
index b8894db..76f06bc 100644
@@ -377,7 +377,11 @@
     {
         msg(M_FATAL, "ERROR: --tls-crypt-v2 not supported");
     }
-    init_key_ctx(key_ctx, &srv_key, &kt, encrypt, "tls-crypt-v2 server key");
+    struct key_parameters srv_key_params;
+
+    key_parameters_from_key(&srv_key_params, &srv_key);
+
+    init_key_ctx(key_ctx, &srv_key_params, &kt, encrypt, "tls-crypt-v2 server key");
     secure_memzero(&srv_key, sizeof(srv_key));
 }
 
tests/unit_tests/openvpn/test_auth_token.c +7 -4
index 8a0c16a..9a21abf 100644
@@ -87,7 +87,8 @@
     struct test_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { 0 };
+    key.hmac_size = 64;     /* 64 byte of 0 */
 
     ctx->kt = auth_token_kt();
     if (!ctx->kt.digest)
@@ -148,15 +149,17 @@
                      AUTH_TOKEN_HMAC_OK);
 
     /* Change auth-token key */
-    struct key key;
-    memset(&key, '1', sizeof(key));
+    struct key_parameters key;
+    memset(key.hmac, '1', sizeof(key.hmac));
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;
+
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
 
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session), 0);
 
     /* Load original test key again */
-    memset(&key, 0, sizeof(key));
+    memset(&key.hmac, 0, sizeof(key.hmac));
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session),
tests/unit_tests/openvpn/test_tls_crypt.c +2 -2
index 4f12f88..f4b30b7 100644
@@ -157,7 +157,7 @@
     struct test_tls_crypt_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 }, .hmac_size = 64, .cipher_size = 64 };
 
     ctx->kt = tls_crypt_kt();
     if (!ctx->kt.cipher || !ctx->kt.digest)
@@ -367,7 +367,7 @@
     skip_if_tls_crypt_not_supported(ctx);
 
     /* Change decrypt key */
-    struct key key = { { 1 } };
+    struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 }, .cipher_size = 64, .hmac_size = 64 };
     free_key_ctx(&ctx->co.key_ctx_bi.decrypt);
     init_key_ctx(&ctx->co.key_ctx_bi.decrypt, &key, &ctx->kt, false, "TEST");
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/801?usp=email )

Change subject: Change API of init_key_ctx to use struct key_paramters
......................................................................

Patch Set 5: Code-Review-2

(5 comments)

File src/openvpn/crypto.h:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/5982a4b7_c94afe48 :
PS5, Line 158: /** internal structure similar to struct key that hold key information "holds"

File src/openvpn/crypto.c:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/c483a455_001f6aab :
PS5, Line 902: ,
Needs update

http://gerrit.openvpn.net/c/openvpn/+/801/comment/59b2558f_a402ae56 :
PS5, Line 915: impl_iv_len
Change to ASSERT(impl_iv_len <= key->hmac_size); to keep consistency

http://gerrit.openvpn.net/c/openvpn/+/801/comment/9992be96_25c470fb :
PS5, Line 1128: key_params->cipher_size = MAX_HMAC_KEY_LENGTH;
MAX_CIPHER_KEY_LENGTH

http://gerrit.openvpn.net/c/openvpn/+/801/comment/b7fb9ae2_fc643aa9 :
PS5, Line 1129: MAX_CIPHER_KEY_LENGTH MAX_HMAC_KEY_LENGTH

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Fri, 29 Nov 2024 16:59:26 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#3 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

plaisthos has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/801?usp=email )

Change subject: Change API of init_key_ctx to use struct key_paramters
......................................................................

Patch Set 5:

(6 comments)

Patchset:

PS5:
thanks for the review

File src/openvpn/crypto.h:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/8d53de3a_4d1c5e54 :
PS5, Line 158: /** internal structure similar to struct key that hold key information

Quoted 1 line

"holds"

Done

File src/openvpn/crypto.c:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/ce856d23_fcfbd114 :
PS5, Line 902: ,

Quoted 1 line

Needs update

Done

http://gerrit.openvpn.net/c/openvpn/+/801/comment/a387265a_62cbf33e :
PS5, Line 915: impl_iv_len

Quoted 1 line

Change to ASSERT(impl_iv_len <= key->hmac_size); to keep consistency

Done

http://gerrit.openvpn.net/c/openvpn/+/801/comment/0fbf3998_33a8a7fa :
PS5, Line 1128: key_params->cipher_size = MAX_HMAC_KEY_LENGTH;

Quoted 1 line

MAX_CIPHER_KEY_LENGTH

Acknowledged

http://gerrit.openvpn.net/c/openvpn/+/801/comment/e070181c_273bb98a :
PS5, Line 1129: MAX_CIPHER_KEY_LENGTH

Quoted 1 line

MAX_HMAC_KEY_LENGTH

Acknowledged

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 30 Nov 2024 12:41:23 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#4 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/801?usp=email

to look at the new patch set (#6).

Change subject: Change API of init_key_ctx to use struct key_paramters
......................................................................

Change API of init_key_ctx to use struct key_paramters

This introduces a new structure key_paramters. The reason is that the current struct serves both as an internal struct as well as an on-wire/in-file format. Separate these two different usages to allow extending the struct.

Change-Id I4a981c5a70717e2276d89bf83a06c7fdbe6712d7

---
M src/openvpn/auth_token.c
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/tls_crypt.c
M tests/unit_tests/openvpn/test_auth_token.c
M tests/unit_tests/openvpn/test_tls_crypt.c

6 files changed, 90 insertions(+), 41 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/801/6

src/openvpn/auth_token.c +4 -1
index 192c7c2..3cf55e8 100644
@@ -152,7 +152,10 @@
     {
         msg(M_FATAL, "ERROR: not enough data in auth-token secret");
     }
-    init_key_ctx(key_ctx, &key, &kt, false, "auth-token secret");
+
+    struct key_parameters key_params;
+    key_parameters_from_key(&key_params, &key);
+    init_key_ctx(key_ctx, &key_params, &kt, false, "auth-token secret");
 
     free_buf(&server_secret_key);
 }
src/openvpn/crypto.c +41 -25

133 lines not on this page · raw message

src/openvpn/crypto.h +31 -8
index 2af6d14..726c07c 100644
@@ -144,7 +144,8 @@
 
 /**
  * Container for unidirectional cipher and HMAC %key material.
- * @ingroup control_processor
+ * @ingroup control_processor. This is used as a wire format/file format
+ * key, so it cannot be changed to add fields or change the length of fields
  */
 struct key
 {
@@ -154,6 +155,30 @@
     /**< %Key material for HMAC operations. */
 };
 
+/** internal structure similar to struct key that holds key information
+ * but is not represented on wire and can be changed/extended
+ */
+struct key_parameters {
+    /** %Key material for cipher operations. */
+    uint8_t cipher[MAX_CIPHER_KEY_LENGTH];
+
+    /** Number of bytes set in the cipher key material */
+    int cipher_size;
+
+    /** %Key material for HMAC operations. */
+    uint8_t hmac[MAX_HMAC_KEY_LENGTH];
+
+    /** Number of bytes set in the HMac key material */
+    int hmac_size;
+};
+
+/**
+ * Converts a struct key representation into a struct key_params representation.
+ * @param key_params    destination for the converted struct
+ * @param key           source of the conversion
+ */
+void
+key_parameters_from_key(struct key_parameters *key_params, const struct key *key);
 
 /**
  * Container for one set of cipher and/or HMAC contexts.
@@ -347,19 +372,17 @@
  * Key context functions
  */
 
-void init_key_ctx(struct key_ctx *ctx, const struct key *key,
+void init_key_ctx(struct key_ctx *ctx, const struct key_parameters *key,
                   const struct key_type *kt, int enc,
                   const char *prefix);
 
 void
-init_key_bi_ctx_send(struct key_ctx *ctx, const struct key2 *key2,
-                     int key_direction, const struct key_type *kt,
-                     const char *name);
+init_key_bi_ctx_send(struct key_ctx *ctx, const struct key_parameters *key,
+                     const struct key_type *kt, const char *name);
 
 void
-init_key_bi_ctx_recv(struct key_ctx *ctx, const struct key2 *key2,
-                     int key_direction, const struct key_type *kt,
-                     const char *name);
+init_key_bi_ctx_recv(struct key_ctx *ctx, const struct key_parameters *key,
+                     const struct key_type *kt, const char *name);
 
 void free_key_ctx(struct key_ctx *ctx);
 
src/openvpn/tls_crypt.c +5 -1
index b8894db..76f06bc 100644
@@ -377,7 +377,11 @@
     {
         msg(M_FATAL, "ERROR: --tls-crypt-v2 not supported");
     }
-    init_key_ctx(key_ctx, &srv_key, &kt, encrypt, "tls-crypt-v2 server key");
+    struct key_parameters srv_key_params;
+
+    key_parameters_from_key(&srv_key_params, &srv_key);
+
+    init_key_ctx(key_ctx, &srv_key_params, &kt, encrypt, "tls-crypt-v2 server key");
     secure_memzero(&srv_key, sizeof(srv_key));
 }
 
tests/unit_tests/openvpn/test_auth_token.c +7 -4
index 8a0c16a..9a21abf 100644
@@ -87,7 +87,8 @@
     struct test_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { 0 };
+    key.hmac_size = 64;     /* 64 byte of 0 */
 
     ctx->kt = auth_token_kt();
     if (!ctx->kt.digest)
@@ -148,15 +149,17 @@
                      AUTH_TOKEN_HMAC_OK);
 
     /* Change auth-token key */
-    struct key key;
-    memset(&key, '1', sizeof(key));
+    struct key_parameters key;
+    memset(key.hmac, '1', sizeof(key.hmac));
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;
+
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
 
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session), 0);
 
     /* Load original test key again */
-    memset(&key, 0, sizeof(key));
+    memset(&key.hmac, 0, sizeof(key.hmac));
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session),
tests/unit_tests/openvpn/test_tls_crypt.c +2 -2
index 4f12f88..f4b30b7 100644
@@ -157,7 +157,7 @@
     struct test_tls_crypt_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 }, .hmac_size = 64, .cipher_size = 64 };
 
     ctx->kt = tls_crypt_kt();
     if (!ctx->kt.cipher || !ctx->kt.digest)
@@ -367,7 +367,7 @@
     skip_if_tls_crypt_not_supported(ctx);
 
     /* Change decrypt key */
-    struct key key = { { 1 } };
+    struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 }, .cipher_size = 64, .hmac_size = 64 };
     free_key_ctx(&ctx->co.key_ctx_bi.decrypt);
     init_key_ctx(&ctx->co.key_ctx_bi.decrypt, &key, &ctx->kt, false, "TEST");
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#5 lore raw
In reply to a message not in the archive

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/801?usp=email )

Change subject: Change API of init_key_ctx to use struct key_paramters
......................................................................

Patch Set 8: -Code-Review

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Comment-Date: Mon, 23 Dec 2024 11:28:43 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#6 lore raw
In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/801?usp=email )

Change subject: Change API of init_key_ctx to use struct key_paramters
......................................................................

Patch Set 8: Code-Review-1

(7 comments)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/d5dc012d_2cbbcd2a :
PS8, Line 7: Change API of init_key_ctx to use struct key_paramters key_parameters

http://gerrit.openvpn.net/c/openvpn/+/801/comment/4aa5e0d0_d728fca3 :
PS8, Line 9: This introduces a new structure key_paramters. The reason is that the key_parameters

Patchset:

PS8:
Typos and nitpicks

File src/openvpn/crypto.h:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/475bd1eb_01333a7a :
PS8, Line 176: * Converts a struct key representation into a struct key_params representation. key_parameters

File tests/unit_tests/openvpn/test_auth_token.c:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/aaed804b_181e091c :
PS8, Line 91: key.hmac_size = 64; /* 64 byte of 0 */
Use MAX_HMAC_KEY_LENGTH instead?

File tests/unit_tests/openvpn/test_tls_crypt.c:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/491ee4f7_038e96a7 :
PS8, Line 160: struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 }, .hmac_size = 64, .cipher_size = 64 };
Use MAX_HMAC_KEY_LENGTH and MAX_CIPHER_KEY_LENGTH instead?

http://gerrit.openvpn.net/c/openvpn/+/801/comment/09708593_0ee44299 :
PS8, Line 370: struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 }, .cipher_size = 64, .hmac_size = 64 };
Use MAX_HMAC_KEY_LENGTH and MAX_CIPHER_KEY_LENGTH instead?

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 8
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Mon, 23 Dec 2024 11:39:32 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment

#7 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Change API of init_key_ctx to use struct key_parameters

In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

Hello flichtenheld,

I'd like you to reexamine a change. Please visit

    http://gerrit.openvpn.net/c/openvpn/+/801?usp=email

to look at the new patch set (#9).

The following approvals got outdated and were removed:
Code-Review-1 by flichtenheld

Change subject: Change API of init_key_ctx to use struct key_parameters
......................................................................

Change API of init_key_ctx to use struct key_parameters

This introduces a new structure key_parameters. The reason is that the current struct serves both as an internal struct as well as an on-wire/in-file format. Separate these two different usages to allow extending the struct.

Change-Id I4a981c5a70717e2276d89bf83a06c7fdbe6712d7

---
M src/openvpn/auth_token.c
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/tls_crypt.c
M tests/unit_tests/openvpn/test_auth_token.c
M tests/unit_tests/openvpn/test_tls_crypt.c

6 files changed, 94 insertions(+), 41 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/801/9

src/openvpn/auth_token.c +4 -1
index 192c7c2..3cf55e8 100644
@@ -152,7 +152,10 @@
     {
         msg(M_FATAL, "ERROR: not enough data in auth-token secret");
     }
-    init_key_ctx(key_ctx, &key, &kt, false, "auth-token secret");
+
+    struct key_parameters key_params;
+    key_parameters_from_key(&key_params, &key);
+    init_key_ctx(key_ctx, &key_params, &kt, false, "auth-token secret");
 
     free_buf(&server_secret_key);
 }
src/openvpn/crypto.c +41 -25

133 lines not on this page · raw message

src/openvpn/crypto.h +33 -8

65 lines not on this page · raw message

src/openvpn/tls_crypt.c +5 -1
index b8894db..76f06bc 100644
@@ -377,7 +377,11 @@
     {
         msg(M_FATAL, "ERROR: --tls-crypt-v2 not supported");
     }
-    init_key_ctx(key_ctx, &srv_key, &kt, encrypt, "tls-crypt-v2 server key");
+    struct key_parameters srv_key_params;
+
+    key_parameters_from_key(&srv_key_params, &srv_key);
+
+    init_key_ctx(key_ctx, &srv_key_params, &kt, encrypt, "tls-crypt-v2 server key");
     secure_memzero(&srv_key, sizeof(srv_key));
 }
 
tests/unit_tests/openvpn/test_auth_token.c +7 -4
index 8a0c16a..be3b2b7 100644
@@ -87,7 +87,8 @@
     struct test_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { 0 };
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;     /* 64 byte of 0 */
 
     ctx->kt = auth_token_kt();
     if (!ctx->kt.digest)
@@ -148,15 +149,17 @@
                      AUTH_TOKEN_HMAC_OK);
 
     /* Change auth-token key */
-    struct key key;
-    memset(&key, '1', sizeof(key));
+    struct key_parameters key;
+    memset(key.hmac, '1', sizeof(key.hmac));
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;
+
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
 
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session), 0);
 
     /* Load original test key again */
-    memset(&key, 0, sizeof(key));
+    memset(&key.hmac, 0, sizeof(key.hmac));
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session),
tests/unit_tests/openvpn/test_tls_crypt.c +4 -2
index 4f12f88..94cd0ee 100644
@@ -157,7 +157,8 @@
     struct test_tls_crypt_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 },
+                                  .hmac_size = MAX_HMAC_KEY_LENGTH, .cipher_size = MAX_CIPHER_KEY_LENGTH };
 
     ctx->kt = tls_crypt_kt();
     if (!ctx->kt.cipher || !ctx->kt.digest)
@@ -367,7 +368,8 @@
     skip_if_tls_crypt_not_supported(ctx);
 
     /* Change decrypt key */
-    struct key key = { { 1 } };
+    struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 },
+                                  .cipher_size = MAX_CIPHER_KEY_LENGTH, .hmac_size = MAX_HMAC_KEY_LENGTH };
     free_key_ctx(&ctx->co.key_ctx_bi.decrypt);
     init_key_ctx(&ctx->co.key_ctx_bi.decrypt, &key, &ctx->kt, false, "TEST");
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 9
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newpatchset

#8 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Change API of init_key_ctx to use struct key_parameters

In reply to a message not in the archive

Attention is currently required from: plaisthos.

flichtenheld has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/801?usp=email )

Change subject: Change API of init_key_ctx to use struct key_parameters
......................................................................

Patch Set 9: Code-Review+2

(6 comments)

Commit Message:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/b730dde1_23369276 :
PS8, Line 7: Change API of init_key_ctx to use struct key_paramters

Quoted 1 line

key_parameters

Done

http://gerrit.openvpn.net/c/openvpn/+/801/comment/38a47023_5a01c0b0 :
PS8, Line 9: This introduces a new structure key_paramters. The reason is that the

Quoted 1 line

key_parameters

Done

File src/openvpn/crypto.h:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/a8cbf2dd_988a8316 :
PS8, Line 176: * Converts a struct key representation into a struct key_params representation.

Quoted 1 line

key_parameters

Done

File tests/unit_tests/openvpn/test_auth_token.c:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/a13bc939_51cc0c94 :
PS8, Line 91: key.hmac_size = 64; /* 64 byte of 0 */

Quoted 1 line

Use MAX_HMAC_KEY_LENGTH instead?

Done

File tests/unit_tests/openvpn/test_tls_crypt.c:

http://gerrit.openvpn.net/c/openvpn/+/801/comment/0f742488_2a2784c8 :
PS8, Line 160: struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 }, .hmac_size = 64, .cipher_size = 64 };

Quoted 1 line

Use MAX_HMAC_KEY_LENGTH and MAX_CIPHER_KEY_LENGTH instead?

Done

http://gerrit.openvpn.net/c/openvpn/+/801/comment/a43379bc_85313073 :
PS8, Line 370: struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 }, .cipher_size = 64, .hmac_size = 64 };

Quoted 1 line

Use MAX_HMAC_KEY_LENGTH and MAX_CIPHER_KEY_LENGTH instead?

Done

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 9
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Comment-Date: Fri, 27 Dec 2024 11:02:22 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: Yes
Comment-In-Reply-To: flichtenheld <[email protected]...>
Gerrit-MessageType: comment

#9 lore raw

PATCH v9 1/1 Change API of init_key_ctx to use struct key_parameters

In reply to a message not in the archive

From: Arne Schwabe <[email protected]...>

This introduces a new structure key_parameters. The reason is that the current struct serves both as an internal struct as well as an on-wire/in-file format. Separate these two different usages to allow extending the struct.

Change-Id I4a981c5a70717e2276d89bf83a06c7fdbe6712d7

---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/801
This mail reflects revision 9 of this Change.

Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]...>

src/openvpn/auth_token.c +4 -1
index 192c7c2..3cf55e8 100644
@@ -152,7 +152,10 @@
     {
         msg(M_FATAL, "ERROR: not enough data in auth-token secret");
     }
-    init_key_ctx(key_ctx, &key, &kt, false, "auth-token secret");
+
+    struct key_parameters key_params;
+    key_parameters_from_key(&key_params, &key);
+    init_key_ctx(key_ctx, &key_params, &kt, false, "auth-token secret");
 
     free_buf(&server_secret_key);
 }
src/openvpn/crypto.c +41 -25

133 lines not on this page · raw message

src/openvpn/crypto.h +33 -8

65 lines not on this page · raw message

src/openvpn/tls_crypt.c +5 -1
index b8894db..76f06bc 100644
@@ -377,7 +377,11 @@
     {
         msg(M_FATAL, "ERROR: --tls-crypt-v2 not supported");
     }
-    init_key_ctx(key_ctx, &srv_key, &kt, encrypt, "tls-crypt-v2 server key");
+    struct key_parameters srv_key_params;
+
+    key_parameters_from_key(&srv_key_params, &srv_key);
+
+    init_key_ctx(key_ctx, &srv_key_params, &kt, encrypt, "tls-crypt-v2 server key");
     secure_memzero(&srv_key, sizeof(srv_key));
 }
 
tests/unit_tests/openvpn/test_auth_token.c +7 -4
index 8a0c16a..be3b2b7 100644
@@ -87,7 +87,8 @@
     struct test_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { 0 };
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;     /* 64 byte of 0 */
 
     ctx->kt = auth_token_kt();
     if (!ctx->kt.digest)
@@ -148,15 +149,17 @@
                      AUTH_TOKEN_HMAC_OK);
 
     /* Change auth-token key */
-    struct key key;
-    memset(&key, '1', sizeof(key));
+    struct key_parameters key;
+    memset(key.hmac, '1', sizeof(key.hmac));
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;
+
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
 
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session), 0);
 
     /* Load original test key again */
-    memset(&key, 0, sizeof(key));
+    memset(&key.hmac, 0, sizeof(key.hmac));
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session),
tests/unit_tests/openvpn/test_tls_crypt.c +4 -2
index 4f12f88..94cd0ee 100644
@@ -157,7 +157,8 @@
     struct test_tls_crypt_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 },
+                                  .hmac_size = MAX_HMAC_KEY_LENGTH, .cipher_size = MAX_CIPHER_KEY_LENGTH };
 
     ctx->kt = tls_crypt_kt();
     if (!ctx->kt.cipher || !ctx->kt.digest)
@@ -367,7 +368,8 @@
     skip_if_tls_crypt_not_supported(ctx);
 
     /* Change decrypt key */
-    struct key key = { { 1 } };
+    struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 },
+                                  .cipher_size = MAX_CIPHER_KEY_LENGTH, .hmac_size = MAX_HMAC_KEY_LENGTH };
     free_key_ctx(&ctx->co.key_ctx_bi.decrypt);
     init_key_ctx(&ctx->co.key_ctx_bi.decrypt, &key, &ctx->kt, false, "TEST");
 
#10 lore raw

[Openvpn-devel] [PATCH applied] Re: Change API of init_key_ctx to use struct key_parameters

I'm not sure I understand all the intricacies here (like, "cipher_size = MAX_CIPHER_KEY_LENGTH", what's that for?), but it passes all the client/server test, memory operations look safe, and it has a unit test and a +2 from Frank :-)

Your patch has been applied to the master branch.

commit 5bbf0aa484470486fcc2f491fba81605aa8649ed

Author: Arne Schwabe
Date:   Fri Dec 27 12:11:33 2024 +0100
     Change API of init_key_ctx to use struct key_parameters

     Signed-off-by: Arne Schwabe <[email protected]...>
     Acked-by: Frank Lichtenheld <[email protected]...>
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg30228.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#11 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Change API of init_key_ctx to use struct key_parameters

In reply to a message not in the archive

cron2 has uploaded a new patch set (#10) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/801?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld

Change subject: Change API of init_key_ctx to use struct key_parameters
......................................................................

Change API of init_key_ctx to use struct key_parameters

This introduces a new structure key_parameters. The reason is that the current struct serves both as an internal struct as well as an on-wire/in-file format. Separate these two different usages to allow extending the struct.

Change-Id I4a981c5a70717e2276d89bf83a06c7fdbe6712d7

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30228.html

---
M src/openvpn/auth_token.c
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/tls_crypt.c
M tests/unit_tests/openvpn/test_auth_token.c
M tests/unit_tests/openvpn/test_tls_crypt.c

6 files changed, 94 insertions(+), 41 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/01/801/10

src/openvpn/auth_token.c +4 -1
index 192c7c2..3cf55e8 100644
@@ -152,7 +152,10 @@
     {
         msg(M_FATAL, "ERROR: not enough data in auth-token secret");
     }
-    init_key_ctx(key_ctx, &key, &kt, false, "auth-token secret");
+
+    struct key_parameters key_params;
+    key_parameters_from_key(&key_params, &key);
+    init_key_ctx(key_ctx, &key_params, &kt, false, "auth-token secret");
 
     free_buf(&server_secret_key);
 }
src/openvpn/crypto.c +41 -25

133 lines not on this page · raw message

src/openvpn/crypto.h +33 -8

65 lines not on this page · raw message

src/openvpn/tls_crypt.c +5 -1
index b8894db..76f06bc 100644
@@ -377,7 +377,11 @@
     {
         msg(M_FATAL, "ERROR: --tls-crypt-v2 not supported");
     }
-    init_key_ctx(key_ctx, &srv_key, &kt, encrypt, "tls-crypt-v2 server key");
+    struct key_parameters srv_key_params;
+
+    key_parameters_from_key(&srv_key_params, &srv_key);
+
+    init_key_ctx(key_ctx, &srv_key_params, &kt, encrypt, "tls-crypt-v2 server key");
     secure_memzero(&srv_key, sizeof(srv_key));
 }
 
tests/unit_tests/openvpn/test_auth_token.c +7 -4
index 8a0c16a..be3b2b7 100644
@@ -87,7 +87,8 @@
     struct test_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { 0 };
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;     /* 64 byte of 0 */
 
     ctx->kt = auth_token_kt();
     if (!ctx->kt.digest)
@@ -148,15 +149,17 @@
                      AUTH_TOKEN_HMAC_OK);
 
     /* Change auth-token key */
-    struct key key;
-    memset(&key, '1', sizeof(key));
+    struct key_parameters key;
+    memset(key.hmac, '1', sizeof(key.hmac));
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;
+
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
 
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session), 0);
 
     /* Load original test key again */
-    memset(&key, 0, sizeof(key));
+    memset(&key.hmac, 0, sizeof(key.hmac));
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session),
tests/unit_tests/openvpn/test_tls_crypt.c +4 -2
index 4f12f88..94cd0ee 100644
@@ -157,7 +157,8 @@
     struct test_tls_crypt_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 },
+                                  .hmac_size = MAX_HMAC_KEY_LENGTH, .cipher_size = MAX_CIPHER_KEY_LENGTH };
 
     ctx->kt = tls_crypt_kt();
     if (!ctx->kt.cipher || !ctx->kt.digest)
@@ -367,7 +368,8 @@
     skip_if_tls_crypt_not_supported(ctx);
 
     /* Change decrypt key */
-    struct key key = { { 1 } };
+    struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 },
+                                  .cipher_size = MAX_CIPHER_KEY_LENGTH, .hmac_size = MAX_HMAC_KEY_LENGTH };
     free_key_ctx(&ctx->co.key_ctx_bi.decrypt);
     init_key_ctx(&ctx->co.key_ctx_bi.decrypt, &key, &ctx->kt, false, "TEST");
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 10
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset

#12 lore raw

[Openvpn-devel] [M] Change in openvpn[master]: Change API of init_key_ctx to use struct key_parameters

In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/801?usp=email )

Change subject: Change API of init_key_ctx to use struct key_parameters
......................................................................

Change API of init_key_ctx to use struct key_parameters

This introduces a new structure key_parameters. The reason is that the current struct serves both as an internal struct as well as an on-wire/in-file format. Separate these two different usages to allow extending the struct.

Change-Id I4a981c5a70717e2276d89bf83a06c7fdbe6712d7

Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg30228.html

---
M src/openvpn/auth_token.c
M src/openvpn/crypto.c
M src/openvpn/crypto.h
M src/openvpn/tls_crypt.c
M tests/unit_tests/openvpn/test_auth_token.c
M tests/unit_tests/openvpn/test_tls_crypt.c

6 files changed, 94 insertions(+), 41 deletions(-)
src/openvpn/auth_token.c +4 -1
index 192c7c2..3cf55e8 100644
@@ -152,7 +152,10 @@
     {
         msg(M_FATAL, "ERROR: not enough data in auth-token secret");
     }
-    init_key_ctx(key_ctx, &key, &kt, false, "auth-token secret");
+
+    struct key_parameters key_params;
+    key_parameters_from_key(&key_params, &key);
+    init_key_ctx(key_ctx, &key_params, &kt, false, "auth-token secret");
 
     free_buf(&server_secret_key);
 }
src/openvpn/crypto.c +41 -25

133 lines not on this page · raw message

src/openvpn/crypto.h +33 -8

65 lines not on this page · raw message

src/openvpn/tls_crypt.c +5 -1
index b8894db..76f06bc 100644
@@ -377,7 +377,11 @@
     {
         msg(M_FATAL, "ERROR: --tls-crypt-v2 not supported");
     }
-    init_key_ctx(key_ctx, &srv_key, &kt, encrypt, "tls-crypt-v2 server key");
+    struct key_parameters srv_key_params;
+
+    key_parameters_from_key(&srv_key_params, &srv_key);
+
+    init_key_ctx(key_ctx, &srv_key_params, &kt, encrypt, "tls-crypt-v2 server key");
     secure_memzero(&srv_key, sizeof(srv_key));
 }
 
tests/unit_tests/openvpn/test_auth_token.c +7 -4
index 8a0c16a..be3b2b7 100644
@@ -87,7 +87,8 @@
     struct test_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { 0 };
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;     /* 64 byte of 0 */
 
     ctx->kt = auth_token_kt();
     if (!ctx->kt.digest)
@@ -148,15 +149,17 @@
                      AUTH_TOKEN_HMAC_OK);
 
     /* Change auth-token key */
-    struct key key;
-    memset(&key, '1', sizeof(key));
+    struct key_parameters key;
+    memset(key.hmac, '1', sizeof(key.hmac));
+    key.hmac_size = MAX_HMAC_KEY_LENGTH;
+
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
 
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session), 0);
 
     /* Load original test key again */
-    memset(&key, 0, sizeof(key));
+    memset(&key.hmac, 0, sizeof(key.hmac));
     free_key_ctx(&ctx->multi.opt.auth_token_key);
     init_key_ctx(&ctx->multi.opt.auth_token_key, &key, &ctx->kt, false, "TEST");
     assert_int_equal(verify_auth_token(&ctx->up, &ctx->multi, ctx->session),
tests/unit_tests/openvpn/test_tls_crypt.c +4 -2
index 4f12f88..94cd0ee 100644
@@ -157,7 +157,8 @@
     struct test_tls_crypt_context *ctx = calloc(1, sizeof(*ctx));
     *state = ctx;
 
-    struct key key = { 0 };
+    struct key_parameters key = { .cipher = { 0 }, .hmac = { 0 },
+                                  .hmac_size = MAX_HMAC_KEY_LENGTH, .cipher_size = MAX_CIPHER_KEY_LENGTH };
 
     ctx->kt = tls_crypt_kt();
     if (!ctx->kt.cipher || !ctx->kt.digest)
@@ -367,7 +368,8 @@
     skip_if_tls_crypt_not_supported(ctx);
 
     /* Change decrypt key */
-    struct key key = { { 1 } };
+    struct key_parameters key = { .cipher = { 1 }, .hmac = { 1 },
+                                  .cipher_size = MAX_CIPHER_KEY_LENGTH, .hmac_size = MAX_HMAC_KEY_LENGTH };
     free_key_ctx(&ctx->co.key_ctx_bi.decrypt);
     init_key_ctx(&ctx->co.key_ctx_bi.decrypt, &key, &ctx->kt, false, "TEST");
 

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/801?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings

Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I4a981c5a70717e2276d89bf83a06c7fdbe6712d7
Gerrit-Change-Number: 801
Gerrit-PatchSet: 10
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged